package com.generalbackend.common.enums;

import java.util.EnumSet;
import java.util.HashMap;

/**
 * 定义一个返回码的枚举类
 * @author tim.xie
 * @date 2021/11/17 16:45
 */
public enum  ReturnCodeEnum {
    SUCCESS(0),FAIL(-1),PARAMS_ERROR(3),DENIED_PERMISSION(4);

    private final int value;
    public static HashMap<Integer, ReturnCodeEnum> map = new HashMap<Integer, ReturnCodeEnum>();

    static {
        for (ReturnCodeEnum e : EnumSet.allOf(ReturnCodeEnum.class)) {
            map.put(e.value, e);
        }
    }
    ReturnCodeEnum(Integer value) {
        this.value = value;
    }
    public Integer getValue() {
        return value;
    }

    public static ReturnCodeEnum getEnum(int index) {
        return map.get(index);
    }

}
